package com.dgshanger.sanhxiaofeisc.mvp.model;

import android.text.TextUtils;

import com.blankj.utilcode.util.EncryptUtils;
import com.dgshanger.sanhxiaofeisc.common.AppApi;
import com.dgshanger.sanhxiaofeisc.entity.PayForDetailEntity;
import com.dgshanger.sanhxiaofeisc.entity.PayResultEntity;
import com.dgshanger.sanhxiaofeisc.mvp.contract.PayForDetailContract;
import com.xx.baseutilslibrary.network.rx.RxHelper;
import com.xx.baseutilslibrary.network.rx.RxHttpObserver;

/**
 * PayForDetailModel
 * 沉迷学习不能自拔
 * Describe：
 * Created by 雷小星🍀 on 2018/5/2 17:20.
 */

public class PayForDetailModel implements PayForDetailContract.Model {
    @Override
    public void loadDetail(String msg_id, RxHttpObserver<PayForDetailEntity> httpObserver) {
        AppApi.Api()
                .notice_detail(PayForDetailEntity.TYPE_PAY_FOR, msg_id)
                .compose(RxHelper.io_main())
                .subscribe(httpObserver);
    }

    @Override
    public void accept(String extra_id, String type, String pay_type, String user_pay_pwd, RxHttpObserver<PayResultEntity> httpObserver) {
        AppApi.Api()
                .otherpay_accept(extra_id, type, pay_type, TextUtils.isEmpty(user_pay_pwd) ? null : EncryptUtils.encryptMD5ToString(user_pay_pwd).toLowerCase())
                .compose(RxHelper.io_main())
                .subscribe(httpObserver);
    }

    @Override
    public void refuse(String extra_id, RxHttpObserver<Object> httpObserver) {
        AppApi.Api()
                .refuse_other_pay(extra_id)
                .compose(RxHelper.io_main())
                .subscribe(httpObserver);
    }
}
